local Lua__mojie = fk.CreateSkill {
    name = "Lua__mojie",
    tags = {Skill.Compulsory},
  }
  
  Fk:loadTranslationTable{
    ["Lua__mojie"] = "魔界",
    [":Lua__mojie"] = "锁定技，当你造成伤害或受到伤害时，若你手牌红色为最多，则改为恢复目标x点体力，若黑色为最多，则伤害+x（x为场上角色人数）",


  }

  Lua__mojie:addEffect(fk.DamageInflicted, {
    can_trigger = function(self, event, target, player, data)
      return player:hasSkill(Lua__mojie.name) and target == player
    end,

    on_use = function(self, event, target, player, data)
        local red = 0
        local black = 0
        for _, id in ipairs(player:getCardIds("h")) do
            if Fk:getCardById(id).color == Card.Red then
                red = red +1
            end
            if Fk:getCardById(id).color == Card.Black then
                black = black +1
            end
        end
        if red >= black then
            local num = #player.room.players
            player.room:recover({
                who = data.to,
                num = num,
                skillName = Lua__mojie.name,
            })
            data:preventDamage()
        end
        if black >= red then
            local num = #player.room.players
            data:changeDamage(num)
        end
    end,
})

Lua__mojie:addEffect(fk.DamageCaused, {
    can_trigger = function(self, event, target, player, data)
      return player:hasSkill(Lua__mojie.name) and target == player
    end,

    on_use = function(self, event, target, player, data)
        local red = 0
        local black = 0
        for _, id in ipairs(player:getCardIds("h")) do
            if Fk:getCardById(id).color == Card.Red then
                red = red +1
            end
            if Fk:getCardById(id).color == Card.Black then
                black = black +1
            end
        end
        if red >= black then
            local num = #player.room.players
            player.room:recover({
                who = data.to,
                num = num,
                skillName = Lua__mojie.name,
            })
            data:preventDamage()
        end
        if black >= red then
            local num = #player.room.players
            data:changeDamage(num)
        end
    end,
})



  
  return Lua__mojie